package com.hlkj.warboot.module_sys.service;

import com.alibaba.fastjson.JSONObject;
import com.hlkj.warboot.configurer.util.base.BaseEntityUtil;
import com.hlkj.warboot.module_sys.entity.MailEntity;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.concurrent.CompletableFuture;

/**
 * @Description 异步任务接口
 * @Author 李星
 * @Date 2019/6/29 22:59
 */
public interface AsynService {
    /*
     * @Description 发送html格式邮件
     * @Author 李星
     * @Date 2019/8/11 17:33
     * @Param [entity]
     * @return java.util.concurrent.CompletableFuture<com.alibaba.fastjson.JSONObject>
     */
    @Async("asyncTaskExecutor")
    CompletableFuture<JSONObject> sendHtmlMail(MailEntity entity);

    /*
     * @Description 上传文件
     * @Author 李星
     * @Date 2019/10/4 21:38
     * @Param [multipartFiles 上传文件对象, baseEntityUtil 通用实体类，存放上传文件时的参数]
     * @return java.util.concurrent.CompletableFuture<com.alibaba.fastjson.JSONObject>
     */
    @Async("asyncTaskExecutor")
    CompletableFuture<JSONObject> uploadFile(BaseEntityUtil baseEntityUtil) throws Exception;

    /*
     * @Description 上传Excel
     * @Author 李星
     * @Date 2019/3/30 15:52
     * @Param [files, baseEntityUtil]
     * @return java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>
     */
    @Async("asyncTaskExecutor")
    CompletableFuture<JSONObject> importDataByExcel(MultipartFile[] multipartFiles, BaseEntityUtil baseEntityUtil) throws Exception;

    /*
     * @Description 上传Excel
     * @Author 李星
     * @Date 2019/3/30 15:52
     * @Param [files, baseEntityUtil]
     * @return java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>>
     */
    @Async("asyncTaskExecutor")
    CompletableFuture<JSONObject> importDataByExcelNew(MultipartFile[] multipartFiles, BaseEntityUtil baseEntityUtil) throws Exception;

    /*
     * @Description 下载文件
     * @Author 李星
     * @Date 2019/7/6 22:37
     * @Param [source 资源文件, response HttpServletResponse]
     * @return java.util.concurrent.CompletableFuture<com.alibaba.fastjson.JSONObject>
     */
    @Async("asyncTaskExecutor")
    void downloadFile(String source, HttpServletResponse response) throws Exception;
}
